<template>
  <button class="box" style="background-color: #4365c3" type="button" @click="toggle">状态切换</button>
  <transition mode="out-in"
              enter-from-class="enter-from"
              leave-to-class="leave-to">
    <LhzOn ref="lhzOn" v-if="isShow"></LhzOn>
    <LhzOff ref="lhzOff" v-else></LhzOff>
  </transition>
</template>

<script>
import LhzOn from "@/components/chap07/LhzOn";
import LhzOff from "@/components/chap07/LhzOff";

export default {
  name: "LhzSwitch",
  data() {
    return {
      isShow: true
    }
  },
  methods: {
    toggle() {
      this.isShow = !this.isShow;
    }
  },
  components: {
    LhzOn, LhzOff
  }
}
</script>

<style scoped>
.box {
  width: 300px;
  height: 100px;
  text-align: center;
  line-height: 100px;
  font-size: 33px;
  color: #ffffff;
  cursor: pointer;
  transition: 500ms all ease;;
}

.enter-from, .leave-to {
  background-color: transparent;
}
</style>